home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / misc / gs261src.zip / gdevx.h < prev    next >
C/C++ Source or Header  |  1993-05-28  |  5KB  |  165 lines

  1. /* Copyright (C) 1989, 1992, 1993 Aladdin Enterprises.  All rights reserved.
  2.  
  3. This file is part of Ghostscript.
  4.  
  5. Ghostscript is distributed in the hope that it will be useful, but
  6. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  7. to anyone for the consequences of using it or for whether it serves any
  8. particular purpose or works at all, unless he says so in writing.  Refer
  9. to the Ghostscript General Public License for full details.
  10.  
  11. Everyone is granted permission to copy, modify and redistribute
  12. Ghostscript, but only under the conditions described in the Ghostscript
  13. General Public License.  A copy of this license is supposed to have been
  14. given to you along with Ghostscript so you can know your rights and
  15. responsibilities.  It should be in a file named COPYING.  Among other
  16. things, the copyright notice and this notice must be preserved on all
  17. copies.  */
  18.  
  19. /* gdevx.h */
  20. /* Header file with X device structure */
  21. /* Requires gxdevice.h and x_.h */
  22.  
  23. /* Define the type of an X pixel. */
  24. typedef unsigned long x_pixel;
  25.  
  26. /* Define a rectangle structure for update bookkeeping */
  27. typedef struct rect_s {
  28.   int xo, yo, xe, ye;
  29. } rect;
  30.  
  31. /* Define PostScript to X11 font name mapping */
  32. struct x11fontmap_s;
  33. typedef struct x11fontmap_s x11fontmap;
  34. struct x11fontmap_s {
  35.     char *ps_name;
  36.     char *x11_name;
  37.     char **std_names;
  38.     char **iso_names;
  39.     int std_count, iso_count;
  40.     x11fontmap *next;
  41. };
  42.  
  43. /* Define the X Windows device */
  44. typedef struct gx_device_X_s {
  45.     gx_device_common;
  46.  
  47.     /* An XImage object for writing bitmap images to the screen */
  48.     XImage image;
  49.  
  50.     /* Global X state */
  51.     Display *dpy;
  52.     Screen *scr;
  53.     XVisualInfo *vinfo;
  54.     Colormap cmap;
  55.     Window win;
  56.     GC gc;
  57.  
  58.     /* A backing pixmap so X will handle exposure automatically */
  59.     Pixmap bpixmap;            /* 0 if useBackingPixmap is false, */
  60.                     /* or if it can't be allocated */
  61.     int ghostview;        /* flag to tell if ghostview is in control */
  62.     Window mwin;        /* window to receive ghostview messages */
  63. /* Don't include standard colormap stuff for X11R3 and earlier */
  64. #if HaveStdCMap
  65.     XStandardColormap *std_cmap;    /* standard color map if available */
  66. #endif
  67.     gs_matrix initial_matrix;    /* the initial transformation */
  68.     Atom next, page, done;    /* Atoms used to talk to ghostview */
  69.     rect update;        /* region needing updating */
  70.     long up_area;        /* total area of update */
  71.                 /* (always 0 if no backing pixmap) */
  72.     int up_count;        /* # of updates since flush */
  73.     Pixmap dest;        /* bpixmap if non-0, else win */
  74.     x_pixel colors_or;    /* 'or' of all device colors used so far */
  75.     x_pixel colors_and;    /* 'and' ditto */
  76.  
  77.     /* An intermediate pixmap for the stencil case of copy_mono */
  78.     struct {
  79.       Pixmap pixmap;
  80.       GC gc;
  81.       int raster, height;
  82.     } cp;
  83.  
  84.     /* Structure for dealing with the halftone tile. */
  85.     /* Later this might become a multi-element cache. */
  86.     struct {
  87.       Pixmap pixmap;
  88.       Pixmap no_pixmap;    /* kludge to get around X bug */
  89.       gx_bitmap_id id;
  90.       int width, height, raster;
  91.       x_pixel fore_c, back_c;
  92.     } ht;
  93.  
  94.     /* Cache the function and fill style from the GC */
  95.     int function;
  96.     int fill_style;
  97.     Font fid;
  98.  
  99. #define set_fill_style(style)\
  100.   if ( xdev->fill_style != style )\
  101.     XSetFillStyle(xdev->dpy, xdev->gc, (xdev->fill_style = style))
  102. #define set_function(func)\
  103.   if ( xdev->function != func )\
  104.     XSetFunction(xdev->dpy, xdev->gc, (xdev->function = func))
  105. #define set_font(font)\
  106.   if ( xdev->fid != font )\
  107.     XSetFont(xdev->dpy, xdev->gc, (xdev->fid = font))
  108.  
  109.     x_pixel back_color, fore_color;
  110.  
  111.     Pixel    background, foreground;
  112. #define cube_index(r,g,b) (((r) * xdev->color_info.dither_rgb + (g)) * \
  113.                   xdev->color_info.dither_rgb + (b))
  114.     x_pixel    *dither_colors;
  115.     ushort    color_mask;
  116.     ushort    half_dev_color;
  117.     XColor    *dynamic_colors;
  118.     int    dynamic_size, dynamic_number;
  119.  
  120. #define note_color(pixel)\
  121.   xdev->colors_or |= pixel,\
  122.   xdev->colors_and &= pixel
  123. #define set_back_color(pixel)\
  124.   if ( xdev->back_color != pixel )\
  125.    { xdev->back_color = pixel;\
  126.      note_color(pixel);\
  127.      XSetBackground(xdev->dpy, xdev->gc, pixel);\
  128.    }
  129. #define set_fore_color(pixel)\
  130.   if ( xdev->fore_color != pixel )\
  131.    { xdev->fore_color = pixel;\
  132.      note_color(pixel);\
  133.      XSetForeground(xdev->dpy, xdev->gc, pixel);\
  134.    }
  135.  
  136.     /* Defautlts set by resources */
  137.     Pixel borderColor;
  138.     Dimension borderWidth;
  139.     String geometry;
  140.     int maxGrayRamp, maxRGBRamp;
  141.     String palette;
  142.     String regularFonts;
  143.     String symbolFonts;
  144.     String dingbatFonts;
  145.     x11fontmap *regular_fonts;
  146.     x11fontmap *symbol_fonts;
  147.     x11fontmap *dingbat_fonts;
  148.     Boolean useXFonts, useScalableFonts, logXFonts;
  149.     float xFontTolerance;
  150.     float xResolution, yResolution;
  151.  
  152.     /* Flags work around various X server problems. */
  153.     Boolean useBackingPixmap;
  154.     Boolean useXPutImage;
  155.     Boolean useXSetTile;
  156.  
  157. } gx_device_X;
  158.  
  159. /* function to keep track of screen updates */
  160. void x_update_add(P5(gx_device *, int, int, int, int));
  161. void gdev_x_clear_window(P1(gx_device_X *));
  162.  
  163. /* Number used to distinguish when resoultion was set from the command line */
  164. #define FAKE_RES (16*72)
  165.